<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue.js"></script>
</head>
<body>
<div id="root">
    <button @click="fn">点我</button>
    <hr/>
    <child/>
</div>
</body>
<script>
    Vue.prototype.$username = "zhangsan";
	const vm = new Vue({
		el: "#root",
        methods:{
			fn(){
				console.log(this === vm,this.__proto__ === Vue.prototype,this.$username);// true
            }
        },
        components:{
			Child:{
				template:(`
				    <button @click="fn">CHILD->点我</button>
				`),
				methods:{
					fn(){
						// 组件实例是通过new VueComponent来实现的
						// console.log("components->Child->methods->fn",this)
						// console.log(this.__proto__ === vm);// false
						// console.log(this.__proto__.__proto__ === Vue.prototype);// true
						console.log(this.$username);
                    }
                }
            }
        }
	});
	console.log(vm,vm.__proto__ === Vue.prototype,vm.$username);// true 'zhangsan'
</script>
</html>